@extends("layouts.backend.webadmin")
@section('page-header')
    <h1>
        <small></small>
    </h1>
@endsection
@section('content')

    <link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/layui/css/layui.css">
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/css/vulslist.css">
    <script src="{{env('APP_ROOT')}}/assets/layui/layui.js"></script>
    <!-- Content Header (Page header) -->

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        {{--<a class="btn btn-primary" href="javascript:;" role="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-search"></i> 搜索</a>--}}
                    </div>
                    <!-- 搜索开始-->
                    <form class="form-inline">
                        <div class="box-body">
                            <div class="row">
                                <!-- /.col -->
                                <!-- /.col -->
                                <div class="col-md-12">
                                    <div class="form-group date">
                                        <div class="row">
                                            <div class="col-xs-1 col-sm-1" ></div>
                                            <div class="input-group">
                                                <input type="text" name="searchKeywords" placeholder="标题"
                                                       class="form-control">
                                                <span class="input-group-btn">
                                                      {{csrf_field()}}
                                                    <button class="btn btn-default" type="submit">搜索</button>
                    </span>
                                            </div>
                                        </div>

                                    </div>


                                </div>
                            </div>
                            <!-- /.row -->
                        </div>
                    </form>
                    <!-- 搜索结束-->
                    <!-- /.box-header -->
                    <div class=" table-responsive">
                        <table id="leveltable" style="table-layout:fixed;width: 98%;margin: 0 auto;"
                               class="table  table-hover table-bordered table-striped">
                            <thead>
                            <tr>
                                <th style="width: 2%;">序号</th>
                                <th style="width: 10%;">公告编号</th>
                                <th style="width: 20%;">公告标题</th>
                                <th style="width: 20%;">公告描述</th>
                                <th style="width: 10%;"> 发布人</th>
                                <th style="width: 10%;">创建时间</th>
                                <th style="width: 7%;">发布状态</th>
                                <th style="width: 20%;">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if($lists->total())
                                @foreach ($lists as $key=>$list)
                                    <tr>
                                        <td style="width: 2%;">{{$key+1}}</td>
                                        <td style="word-break: break-all">
                                            @if(isset($list->sn))
                                                {{$list->sn}}
                                            @endif
                                        </td>
                                        <td>{{$list->title}}</td>
                                        <td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"
                                            data-toggle="tooltip"
                                            title="{{$list->description}}">{{$list->description}}</td>
                                        <td>{{$list->name}}</td>
                                        <td>{{$list->created_at}}</td>

                                        <td>
                                            @if($list->is_publish==0)
                                                未发布
                                            @else
                                                已发布
                                            @endif
                                        </td>
                                        <td>
                                            <div class="btn-group">
                                            <a class="btn @if($list->is_publish==0) btn-success @else btn-default @endif btn-sm vuls-checkForm"
                                               href="{{  URL::route('admin.announce.publish',['id'=>$list->id]) }}"
                                               role="button"><i class="fa fa-pencil fa-fw"></i>发布</a>
                                            <a class="btn btn-success btn-sm vuls-checkForm"
                                               href="{{  URL::route('admin.announce.modify',['id'=>$list->id]) }}"
                                               role="button"><i class="fa fa-pencil fa-fw"></i>修改</a>
                                            <a class="btn btn-primary btn-sm vuls-detail"
                                               href="{{ URL::route('admin.announce.det',['id'=>$list->id]) }}"
                                               role="button"><i class="fa fa-eye fa-fw"></i>详情</a>
                                            <a class="deletes btn btn-primary btn-sm vuls-detail" href="javascript:void(0)"
                                               data-url="{{ URL::route('admin.announce.del',['id'=>$list->id]) }}"
                                               role="button"><i class="fa fa-eye fa-fw"></i>删除</a>
                                            </div>
                                        </td>

                                    </tr>
                                @endforeach

                                @else

                                <tr><td colspan="8" style="text-align: center">暂无数据</td></tr>
                            @endif
                            </tbody>
                            <tfoot>
                            </tfoot>
                        </table>
                    </div>
                {{ $lists->links("mypage.page") }}
                <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <input type="hidden" id="errors" value="{{session('log_error')}}">
        @if(session('log_error'))
            <script type="text/javascript">
                var message = $("#errors").val();
                layui.use('layer', function () {
                    var layer = layui.layer;
                    layer.open({
                        title: '错误提示'
                        , content: message
                    });
                });
            </script>

    @endif
    <!-- /.row -->
    </section>
    <!-- /.content -->
@stop

@section('javascript-end')

    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#startTime', //指定元素
                type: 'datetime'
                , theme: 'molv'
            });
            laydate.render({
                elem: '#endTime', //指定元素
                type: 'datetime'
                , theme: 'molv'
            });
        });


    </script>
    <script>
        layui.use('layer')
        $(function () {
            $(".deletes").click(function () {
                var url=$(this).attr("data-url")
                layer.confirm('确认要删除吗？', {
                    btn: ['确定', '取消']//按钮
                }, function (index) {
                    layer.close(index);
                    window.location.href=url
                })
            })
        })
    </script>

@endsection